package com.example.game_forum.controller;

import com.example.game_forum.dto.TCommentContentDto;
import com.example.game_forum.dto.TCommentDto;
import com.example.game_forum.service.TCommentService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/userapi/t-comment")
@Tag(name = "评论管理", description = "评论的增删改查接口")
public class TCommentController {

    @Autowired
    private TCommentService commentService;

    @PostMapping("/add")
    public ResponseEntity<Void> addComment(@Valid @RequestBody TCommentDto commentDto) {
        commentService.addComment(commentDto);
        return ResponseEntity.ok().build();
    }

    @PostMapping("/reply")
    public ResponseEntity<Void> replyComment(@Valid @RequestBody TCommentDto commentDto,@RequestParam String parentId){
        commentService.replyComment(commentDto,parentId);
        return ResponseEntity.ok().build();
    }

    @PutMapping("/update")
    public ResponseEntity<Void> updateComment(@RequestParam String commentId, @Valid @RequestBody String comment) {
        commentService.updateComment(commentId, comment);
        return ResponseEntity.ok().build();
    }

    @DeleteMapping("/delete")
    public ResponseEntity<Void> deleteComment(@RequestParam String commentId) {
        commentService.deleteComment(commentId);
        return ResponseEntity.ok().build();
    }
}
